/*
 * #%L
 * SwiftUICommonUtilities
 * $Id:$
 * $HeadURL:$
 * %%
 * Copyright (C) 2011 - 2012 Linkwithweb
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public 
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/gpl-3.0.html>.
 * #L%
 */
/**
 * 
 */
package com.linkwithweb.products.swiftui.spring.jdbc;

/**
 * This Object Stores Metadata Information of columns in tables. Like Not
 * Null,Column Length, ColumnType
 * 
 * @author ashwin
 * 
 */
public class ColumnMetadata {
	String catalogName = "";
	String columnClassName = "";
	Integer columnDisplaySize;
	String columnLabel = "";
	String columnName = "";
	Integer columnType = 1;
	String columnTypeName = "";
	Integer precision = 0;
	Integer scale;
	String schemaName = "";
	String tableName = "";
	Boolean isAutoIncrement = false;
	Boolean isCurrency = false;
	Boolean isNullable = false;
	Boolean isSigned = false;

	/**
	 * @param catalogName
	 *            the catalogName to set
	 */
	public void setCatalogName(String catalogName) {
		this.catalogName = catalogName;
	}

	/**
	 * @param columnClassName
	 *            the columnClassName to set
	 */
	public void setColumnClassName(String columnClassName) {
		this.columnClassName = columnClassName;
	}

	/**
	 * @param columnDisplaySize
	 *            the columnDisplaySize to set
	 */
	public void setColumnDisplaySize(Integer columnDisplaySize) {
		this.columnDisplaySize = columnDisplaySize;
	}

	/**
	 * @param columnLabel
	 *            the columnLabel to set
	 */
	public void setColumnLabel(String columnLabel) {
		this.columnLabel = columnLabel;
	}

	/**
	 * @param columnName
	 *            the columnName to set
	 */
	public void setColumnName(String columnName) {
		this.columnName = columnName;
	}

	/**
	 * @param columnType
	 *            the columnType to set
	 */
	public void setColumnType(Integer columnType) {
		this.columnType = columnType;
	}

	/**
	 * @param columnTypeName
	 *            the columnTypeName to set
	 */
	public void setColumnTypeName(String columnTypeName) {
		this.columnTypeName = columnTypeName;
	}

	/**
	 * @param precision
	 *            the precision to set
	 */
	public void setPrecision(Integer precision) {
		this.precision = precision;
	}

	/**
	 * @param scale
	 *            the scale to set
	 */
	public void setScale(Integer scale) {
		this.scale = scale;
	}

	/**
	 * @param schemaName
	 *            the schemaName to set
	 */
	public void setSchemaName(String schemaName) {
		this.schemaName = schemaName;
	}

	/**
	 * @param tableName
	 *            the tableName to set
	 */
	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	/**
	 * @param isAutoIncrement
	 *            the isAutoIncrement to set
	 */
	public void setAutoIncrement(Boolean isAutoIncrement) {
		this.isAutoIncrement = isAutoIncrement;
	}

	/**
	 * @param isCurrency
	 *            the isCurrency to set
	 */
	public void setCurrency(Boolean isCurrency) {
		this.isCurrency = isCurrency;
	}

	/**
	 * @param isNullable
	 *            the isNullable to set
	 */
	public void setNullable(Boolean isNullable) {
		this.isNullable = isNullable;
	}

	/**
	 * @param isSigned
	 *            the isSigned to set
	 */
	public void setSigned(Boolean isSigned) {
		this.isSigned = isSigned;
	}

	/**
	 * @return
	 */
	public String getCatalogName() {
		// TODO Auto-generated method stub
		return catalogName;
	}

	public String getColumnClassName() {
		// TODO Auto-generated method stub
		return columnClassName;
	}

	public Integer getColumnDisplaySize() {
		// TODO Auto-generated method stub
		return columnDisplaySize;
	}

	public String getColumnSize() {
		if (columnDisplaySize == null || columnDisplaySize <= 10)
			return "10";
		else {
			return String.valueOf(columnDisplaySize);
		}
	}
	
	
	public Integer getColumnWidth() {
		if (columnDisplaySize == null || columnDisplaySize <= 10)
			return 10*5;
		else {
			return columnDisplaySize*5;
		}
	}	

	public String getColumnLabel() {
		// TODO Auto-generated method stub
		return columnLabel;
	}

	public String getColumnName() {
		// TODO Auto-generated method stub
		return columnName;
	}

	public Integer getColumnType() {
		// TODO Auto-generated method stub
		return columnType;
	}

	public String getColumnTypeName() {
		// TODO Auto-generated method stub
		return columnTypeName;
	}

	public Integer getPrecision() {
		// TODO Auto-generated method stub
		return precision;
	}

	public Integer getScale() {
		// TODO Auto-generated method stub
		return scale;
	}

	public String getSchemaName() {
		// TODO Auto-generated method stub
		return schemaName;
	}

	public String getTableName() {
		// TODO Auto-generated method stub
		return tableName;
	}

	public Boolean isAutoIncrement() {
		// TODO Auto-generated method stub
		return isAutoIncrement;
	}

	public Boolean isCurrency() {
		// TODO Auto-generated method stub
		return isCurrency;
	}

	public Boolean isNullable() {
		// TODO Auto-generated method stub
		return isNullable;
	}

	public Boolean isSigned() {
		// TODO Auto-generated method stub
		return isSigned;
	}

	public String getNullableString() {
		if (isNullable) {
			return " DEFAULT NULL ";
		} else {
			return " NOT NULL ";
		}
	}

	public String getIdentityString() {
		if (isAutoIncrement) {
			return " AUTO_INCREMENT ";
		} else {
			return "";
		}
	}

	public String getSignString() {
		if (isSigned) {
			return " UNSIGNED ";
		}
		return "";
	}

}
